<!DOCTYPE HTML>
<html lang="cn" xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org">
<head>
    <%include("/common/header.html",{title:''}){}%>
    <title>数据展示</title>

    <style>
        .divcss5-b {
            width: 100%;
            height: 600px;
            overflow-y: scroll;
            overflow-x: hidden;
        }

        .topp {
            background-color: white;
        }

        table, th, td {
            height: 32px;
            width: 300px;
            border: 1px solid #abbac3;
        }

        table tr:hover {
            background-color: #dafdf3;
        }

        .one {
            width: 338px;
            height: 240px;
            border: 1px solid #616366;
            background-color: #fff;
        }

        .qqq {


        }

        .yuan {
            background-color: #1abc9c;
            height: 40px;
            width: 340px;
            border-radius: 30px 30px 0 0;
            text-align: center;
            font-size: 20px;
            line-height: 50px;
            color: #ffffff;
            margin-top: -20px;
        }

        .AnNiu {
            border-radius: 100px;
            background-color: #FF0000;
            width: 50px;
            height: 50px;
            color: #FFFFFF;
            font-size: 28px;
            outline: none;
            border: none;
        }

        .an1 {
            border-radius: 100px;
            background-color: #1abc9c;
            width: 20px;
            height: 20px;
        }

        table tr:nth-child(even) {

            background: #dafdf3;

        }


    </style>

</head>
<script type="text/javascript" src="//api.map.baidu.com/api?v=2.0&ak=IENn7ABARjQIkTeAKyh80VTkg2jYXf3K"></script>

<body>


<div class="x-nav" style="margin: 20px auto auto 15px;">
      <span class="layui-breadcrumb" lay-filter="breadcrumb" style="visibility: visible;">
        <a href="javascript:">首页</a><span lay-separator="">/</span>
        <a href="javascript:">数据展示</a>
      </span>
    <a class="layui-btn layui-btn-primary layui-btn-small" style="margin: -5px 14px 0px 0px;float:right;"
       href="javascript:location.replace(location.href);" title="刷新">
        <i class="layui-icon layui-icon-refresh-3"></i>
    </a>
</div>
<div style="width: 100%;height: 700px;border:1px solid #cccccc;position:relative;top:25px">
    <div style="position:absolute;font-size: 15px;top:10px;left: 10px">

    </div>

    <%for(m in mlist){%>


        <div style="width: 26%;height: 350px;text-align: center;margin-left: 5%;margin-top: 5%;float: left;">
            <div class="yuan">
                沈阳
            </div>
            <div class="one">
                <div style="height: 90px;position:relative">
                    <div style="position:absolute;
                background-color: red;
                width: 25px;height:25px;border-radius:0px 0px 25px 0px;">
                    </div>
                    <div style="position:absolute;left: 150px;top: 30px;text-align: center">

                        <span style="font-size:20px;">当前等级:</span>
                        <div style="float: right;margin-top: -15px">
                            <span style="font-size: 40px;color: #f0ad4e;"> Ⅳ</span>
                        </div>
                    </div>
                </div>
                <div class="qqq">
                    <table style=" text-align: center;margin-left: 18px">
                        <tr>
                            <td width="300px">所属河流</td>
                            <td width="300px">浑河</td>
                        </tr>
                        <tr>
                            <td width="300px">相关变量名称</td>
                            <td width="300px">温湿度</td>
                        </tr>
                        <tr>
                            <td width="300px">超标阈值</td>
                            <td width="300px">3.0</td>
                        </tr>
                        <tr>
                            <td width="300px">说明文字</td>
                            <td width="300px">我打算</td>
                        </tr>
                    </table>
                </div>
            </div>
        </div>
    <%}%>
</div>

<%include("/common/foot.html"){}%>
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/echarts/dist/echarts.min.js"></script>
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/echarts-gl/dist/echarts-gl.min.js"></script>
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/echarts-stat/dist/ecStat.min.js"></script>
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/echarts/dist/extension/dataTool.min.js"></script>
<script>
    layui.use(['index', 'table', 'form', 'laydate', 'layedit', 'AjaxCommon', 'AliangLayui'], function () {
        var $ = layui.$;
        var table = layui.table;
        var form = layui.form;
        var laydate = layui.laydate;
        var AjaxCommon = layui.AjaxCommon;
        var AliangLayui = layui.AliangLayui;

        var title = "监测数据信息";
        var size = ["1200px","450px"];
        var findAll_url='monitoringdat/list.json';
        var update_url='monitoringdat/update.jhtml';
        var delete_url='monitoringdat/delete.jhtml';

        var cols = [ //表头
            {checkbox: true,fixed:true},
            {field: 'rivers_name',   title: '所属区域'},
            {field: 'variable_name',   title: '相关变量名称'},
            {field: 'name',   title: '名称'},
            {field: 'targetlevel',   title: '目标等级'},
            {field: 'exceedingthreshold',   title: '超标阈值'},
            {field: 'content',   title: '说明文字'},
            // {field: 'createtime', templet:"<div>{{layui.util.toDateString(d.createtime, 'yyyy-MM-dd HH:mm:ss')}}</div>",title: '发布时间'},
            {title:'操作', width:147, toolbar: '#table-useradmin-webuser',fixed:'right'}
        ];
        table.render({
            elem: '#LAY-user-manage',
            id: 'listReload',
            toolbar: '#toolbarDemo',
            title: title,
            url: findAll_url,
            page: true, //开启分页
            limits: [10, 20, 30, 50], //控制多少行一页（默认五条一页）
            defaultToolbar: ['filter', 'print', 'exports'],
            cols: [cols],
            done() {
                //alert() 数据渲染完的方法
            }
        });

        // laydate.render({
        //     elem: '#start',
        // });
        // laydate.render({
        //     elem: '#end'//指定元素
        // });

        //自定义验证规则
        form.verify({
            required : [ /[\S]+/, "必填项不能为空" ],

        });

        //初始化修改页面
        function loadData(data){
            var ret={
                "id": data.id,
                "title": data.title,
                "content": data.content

            };
            $("#tb").html(data.content);
            //$("#ym").text(data.content);

            return ret;
        }




        //初始化日期模块
        laydate.render({
            elem: '#create' //指定元素
        });
        //////////////////////////////////////以上是修改每个页面修改的地方
        //弹出修改页面调用初始化数据方法
        function initUpdate(data){
            //alert(data.id);
            //table.reload('listReload');
            layer.open({
                title: title,
                area: size,
                type: 1,
                content: $('#layuiadmin-form-useradmin'), //这里content是一个DOM，注意：最好该元素要存放在body最外层，否则可能被其它的相对元素所影响
                btn: ['关闭'] //可以无限个按钮
            });
            if(data==0 || data==null){
                //$(":reset").click()
                $('#myform')[0].reset();
                return;
            }
            layui.form.val("component-form-element",loadData(data));
        }
        //修改页面的内容提交到后台处理
        form.on('submit(component-form-element)', function(data){
            postUpdate(data);
            return false;
        });
        //头工具栏事件
        table.on('toolbar(LAY-user-manage)', function(obj) {
            var checkStatus = table.checkStatus(obj.config.id);
            switch (obj.event) {
                case 'add':
                    initUpdate(0);
                    break;
                case 'delete':
                    var data = checkStatus.data;
                    if (data.length > 0) {
                        //var id = new Array(); //声明数组
                        for (var i in data) {
                            var a = data[i].id;//得到复选框的值
                            postDelete(a);
                        }
                        /*layer.confirm('删除以后数据将不能恢复，确定删除吗？', function(index) {
                            //alert(data.id);
                            postDelete(id);
                        });*/
                        //alert(id)
                        //layer.alert(JSON.stringify(data));
                        //layer.close(index);
                    } else {
                        layer.msg("至少选择一个进行删除");
                    }
                    break;
                case 'export':
                    layer.msg("导出");
                    break;
            }
        });










        //点击每行右工具栏“操作”里面按钮效果
        table.on('tool(LAY-user-manage)', function(obj) {
            var data = obj.data;
            if (obj.event === 'detail') {
                layer.msg('ID：' + data.id + ' 的查看操作');
            } else if (obj.event === 'edit') {
                initUpdate(data);
            } else if (obj.event === 'del') {
                layer.confirm('删除以后数据将不能恢复，确定删除吗？', function(index) {
                    //alert(data.id);
                    postDelete(data.id);
                });
            }
        });


        //监听搜索按钮效果
        form.on('submit(LAY-user-front-search)', function(data) {
            var field = data.field;
            table.reload('listReload', {
                where :{
                    name: field.name,
                    price: field.price,
                    pay: field.pay
                },
                page: {
                    curr: 1
                }
            });
        });

        //ajax提交删除内容
        window.postDelete = function (id){
            $.ajax({
                url : delete_url,
                type : "POST",
                data : {
                    "id" : id
                },
                dataType : "json",
                success : function(ret) {
                    if (ret == null) {
                        layer.msg("删除失败", {
                            icon : 5
                        });
                    } else {
                        layer.msg("删除成功", {
                            icon : 6
                        });
                        layer.closeAll();
                        table.reload('listReload');
                    }
                    return ret;
                },
                error:function(jqXHR, textStatus, errorThrown){
                    var estr="Page:"+window.location.pathname+",Function: postDelete()";
                    layer.open({
                        title: "错误信息",
                        area: ['600px', '600px'],
                        type: 2,
                        content: "base/error.jhtml?info="+estr, //
                        btn: ['关闭'] //可以无限个按钮
                    });
                }
            });
        };

        //ajax提交修改内容
        window.postUpdate = function (data){
            var formData = new FormData();
            // 利用append的内置方式
            formData.append("data", JSON.stringify(data.field));

            $.ajax({
                url: update_url,
                type: "POST",
                //traditional:true,
                data: formData,
                processData: false,
                contentType: false,
                success: function (data) {
                    if (data.code == 0) {
                        layer.closeAll();
                        layer.msg(data.msg, {time: 600, icon: 1}, function () {
                            //table.reload('listReload');

                        });
                        location.replace(location.href);
                    } else {
                        layer.msg(data.msg, {icon: 6});
                    }
                },
                error: function (jqXHR, textStatus, errorThrown) {
                    var estr="Page:"+window.location.pathname+",Function:postUpdate()";
                    layer.open({
                        title: "错误信息",
                        type: 2,
                        content:  "base/error.jhtml?info="+estr,
                        btn: ['关闭'] //可以无限个按钮
                    });
                }
            });
        }
    });


</script>


</body>

</html>
